// https://leetcode.cn/problems/find-smallest-letter-greater-than-target/description/


func nextGreatestLetter(letters []byte, target byte) byte {
    ans := letters[0]
	flag := false
	for i := 1; i < len(letters); i++ {
		if letters[i] > target {
			if !flag {
				ans = letters[i]
				flag = true
			} else {
				ans = min(ans, letters[i])
			}
		}
	}
	return ans
}

func main() {
	nextGreatestLetter()
}